﻿///团购倒计时
function GroupTime(obj, grouptime,addtionstyle) {
    this.Show = function () {
        var endtime = new Date(grouptime);
        var nowtime = new Date();
        var leftsecond = parseInt((endtime.getTime() - nowtime.getTime()) / 1000);
        var day = parseInt(leftsecond / 3600 / 24);
        var hour = parseInt((leftsecond / 3600) % 24);
        var minute = parseInt((leftsecond / 60) % 60);
        var ssecond = parseInt(leftsecond % 60);

        if (leftsecond <= 0) {
            obj.html("很遗憾，活动已经结束啦！");
            clearInterval(Interval);
            return
        }
        if (addtionstyle == true) {
            
            obj.html(AddtionLabel(day) + "天 " + AddtionLabel(hour) + "小时" + AddtionLabel(minute) + "分" + AddtionLabel(ssecond) + "秒");
        }
        else
        obj.html(day + "天 " + hour + "小时" + minute + "分" + ssecond + "秒");
    }
    var Interval = setInterval(this.Show, 100);

    function AddtionLabel(str)
    { return "<label>" + str +"</label>"; }
}
